Skip to content

@W-18669892 - Add Inventory Filter to PLP #2546

Merged
shauryemahajanSF merged 13 commits intofeature/shop-in-storefrom
sm/addStoreFilterOnPLP
Jun 12, 2025
Merged

@W-18669892 - Add Inventory Filter to PLP #2546
shauryemahajanSF merged 13 commits intofeature/shop-in-storefrom
sm/addStoreFilterOnPLP

Conversation

@shauryemahajanSF
Copy link
Contributor

@shauryemahajanSF shauryemahajanSF commented Jun 10, 2025

Description

This PR adds a Shop by Availability filter on the PLP that allows shoppers to view products based on their selected store. Additionally, no results page still shows filters so that they can be unchecked so a user can return back to the previous state easily.

PLP.Inventory.Filter.mp4

Notes:

  1. A universal selectedStoreContext/ useSelectedStore hook will be added in a future PR which will coordinate store locators called from any place. Right now page re-renders will only happen from store locator called from PLP.

Types of Changes

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Documentation update
  • Breaking change (could cause existing functionality to not work as expected)
  • Other changes (non-breaking changes that does not fit any of the above)

Breaking changes include:

  • Removing a public function or component or prop
  • Adding a required argument to a function
  • Changing the data type of a function parameter or return value
  • Adding a new peer dependency to package.json

Changes

  • Shown in video above

How to Test-Drive This PR

  • (step1)

Checklists

General

  • Changes are covered by test cases
  • CHANGELOG.md updated with a short description of changes (not required for documentation updates)

Accessibility Compliance

You must check off all items in one of the follow two lists:

  • There are no changes to UI

or...

Localization

  • Changes include a UI text update in the Retail React App (which requires translation)

@shauryemahajanSF shauryemahajanSF added the skip changelog Skip the "Changelog Check" GitHub Actions step even if the Changelog.md files are not updated label Jun 10, 2025
@cc-prodsec
Copy link
Collaborator

cc-prodsec commented Jun 10, 2025

🎉 Snyk checks have passed. No issues have been found so far.

security/snyk check is complete. No issues have been found. (View Details)

license/snyk check is complete. No issues have been found. (View Details)

Signed-off-by: shauryemahajanSF <143645277+shauryemahajanSF@users.noreply.github.com>
@@ -426,225 +427,240 @@ const ProductList = (props) => {
return <meta name={id} content={value} key={id} />
})}
</Helmet>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only changes in this file is adding inventory filter and moving showNoResults check down to the product grid so that filters can still be set/unset when no products show up. The other code is unchanged, just un-indented.

@shauryemahajanSF shauryemahajanSF marked this pull request as ready for review June 10, 2025 17:44
@shauryemahajanSF shauryemahajanSF requested a review from a team as a code owner June 10, 2025 17:44
Copy link
Contributor

@patricksullivansf patricksullivansf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome

},
"empty_search_results.info.cant_find_anything_for_category": {
"defaultMessage": "We couldnt find anything for {category}. Try searching for a product or {link}."
"defaultMessage": "We couldn't find anything for {category}. Try searching for a product or {link}."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree the acute accent is weird here, but why fix it as part of this PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops accident


try {
const storeInfoKey = `store_${siteId}`
const storeInfo = JSON.parse(window.localStorage.getItem(storeInfoKey) || 'null')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aside: the reliance on localStorage as the source of truth for our initial PRs troubles me when the end solution was moving the state provider up the DOM. hopefully this at least encapsulates it somewhat...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup see what you're saying, luckily its just defined here - I'll start on store location provider right after this so shouldn't be too bad.


const isChecked = selectedFilters?.ilids !== undefined

useEffect(() => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this is the common piece, which we will handle in refactor story

@aditek-sf
Copy link
Contributor

@shauryemahajanSF just curious on adding the skip changelog label for this change, do we need to make a note of this in the changelog file?

}))

jest.mock('@salesforce/retail-react-app/app/components/store-locator-modal', () => {
// eslint-disable-next-line react/prop-types
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was there a need to disable the linting check?

Copy link
Contributor Author

@shauryemahajanSF shauryemahajanSF Jun 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without this we get linting errors around prop validation, but we don't need to define props here since its just a unit test

@shauryemahajanSF
Copy link
Contributor Author

@shauryemahajanSF just curious on adding the skip changelog label for this change, do we need to make a note of this in the changelog file?

Was thinking we can just have a concise changelog when we merge into develop

setSelectedStore(storeInfo)

// Apply the filter when a store is selected from the locator
toggleFilter({value: storeInfo.inventoryId}, 'ilids', false, false)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we have a future WI, where we dont add the ilids refinement in the URL params?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@snilakandan13
Copy link
Contributor

@shauryemahajanSF - dont you need a changelog.md file

Copy link
Contributor

@snilakandan13 snilakandan13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, the ilids in a future PR will no longer be added to URL parameter

Copy link
Contributor

@aditek-sf aditek-sf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@shauryemahajanSF shauryemahajanSF merged commit 61aa60d into feature/shop-in-store Jun 12, 2025
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip changelog Skip the "Changelog Check" GitHub Actions step even if the Changelog.md files are not updated

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants